#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

#这种模式是直接在构建镜像的内部编译发布dotnet项目。
#注意下容器内输出端口是9291
#如果你想先手动dotnet build成可执行的二进制文件，然后再构建镜像，请看.Api层下的dockerfile。


FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
WORKDIR /src
COPY ["banyuetan_2_0.Api/banyuetan_2_0.Api.csproj", "banyuetan_2_0.Api/"]
COPY ["banyuetan_2_0.Extensions/banyuetan_2_0.Extensions.csproj", "banyuetan_2_0.Extensions/"]
COPY ["banyuetan_2_0.Tasks/banyuetan_2_0.Tasks.csproj", "banyuetan_2_0.Tasks/"]
COPY ["banyuetan_2_0.IServices/banyuetan_2_0.IServices.csproj", "banyuetan_2_0.IServices/"]
COPY ["banyuetan_2_0.Model/banyuetan_2_0.Model.csproj", "banyuetan_2_0.Model/"]
COPY ["banyuetan_2_0.Common/banyuetan_2_0.Common.csproj", "banyuetan_2_0.Common/"]
COPY ["banyuetan_2_0.Services/banyuetan_2_0.Services.csproj", "banyuetan_2_0.Services/"]
COPY ["banyuetan_2_0.Repository/banyuetan_2_0.Repository.csproj", "banyuetan_2_0.Repository/"]
COPY ["banyuetan_2_0.EventBus/banyuetan_2_0.EventBus.csproj", "banyuetan_2_0.EventBus/"]
RUN dotnet restore "banyuetan_2_0.Api/banyuetan_2_0.Api.csproj"
COPY . .
WORKDIR "/src/banyuetan_2_0.Api"
RUN dotnet build "banyuetan_2_0.Api.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "banyuetan_2_0.Api.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
EXPOSE 9291 
ENTRYPOINT ["dotnet", "banyuetan_2_0.Api.dll"]